/ Assembly List / LJCNetCommon / NetCommon / XmlDeserialize

Namespace - LJCNetCommon


Parameters
type - The object type.
fileSpec - The input file spec.
rootName - The Root Name value.

Returns

The deserialized object.

Syntax

C#
public static Object XmlDeserialize(Type type, String fileSpec, String rootName = null)

Deserialize an XML message file to an object. (E)

Example

C#
using LJCNetCommon;
      
public class Person
{
  public long Id { get; set; }
  public string Name { get; set; }
  public bool PrincipleFlag { get; set; }
}
        
// Deserialize an XML message file to an object.
private static void XmlDeserialize()
{
  // Setup
  var person = new Person()
  {
    Id = 1,
    Name = "Text",
    PrincipleFlag = true
  };
  string file = "Text.xml";
  NetCommon.XmlSerialize(person.GetType(), person, null, file);

  // Deserialize an XML message file to an object.
  Person newPerson;
  newPerson = NetCommon.XmlDeserialize(typeof(Person), file) as Person;
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.